package com.haoshuang.zhouzhoubang.ui.vm

import androidx.lifecycle.rxLifeScope
import com.haoshuang.zhouzhoubang.base.request
import com.haoshuang.zhouzhoubang.model.bean.ShoukBean
import com.mufeng.libs.base.BaseViewModel
import com.mufeng.libs.state.StateData
import com.mufeng.libs.state.StatefulMutableLiveData


class ShouKuanViewModel : BaseViewModel() {
    val getLogistics = StatefulMutableLiveData<ShoukBean>()
    fun getLogistics(vararg params: Pair<String, Any?>) {
        rxLifeScope.launch {
            request<ShoukBean>("/api/auth_api/create_pay_qrcode", *params,
                onStart = {
                    getLogistics.value = StateData.Loading
                },
                onError = { code, msg ->
                    getLogistics.value = StateData.Error(code, msg)
                }, onSuccess = {
                    getLogistics.value = StateData.Success(it)
                })
        }
    }
}